<?php
include_once('config/config.php');
$LoginAdmin = $_COOKIE['LoginAdmin'] ? $_COOKIE['LoginAdmin'] : '';
if(empty($LoginAdmin)){
    ShowMsg('请先登录','login.php');
    exit;
}

$LoginAdminList = dbAll('SELECT * FROM `admin`');
$adminId = '';

foreach($LoginAdminList as $item){
    $reAdmin = md5($item['id'].$item['salt']);
    if($LoginAdmin == $reAdmin){
        $adminId = $item['id'];
        break;
    }
}

$LoginAdmin = dbFind("SELECT * FROM `admin` WHERE `id` = '$adminId'");
if(!$LoginAdmin){
    setcookie('LoginAdmin',null);
    ShowMsg('非法登录','login.php');
    exit;
}
?>
<div class="navbar">
    <div class="navbar-inner">
        <ul class="nav pull-right">
            <li>
                <a href="#" role="button">
                    <i class="icon-user"></i><?php echo $LoginAdmin['username']; ?>
                </a>
            </li>
            <li>
                <a href="logut.php" class="hidden-phone visible-tablet visible-desktop" role="button">退出</a>
            </li>
        </ul>
        <a class="brand" href="index.php"><span class="second">后台管理</span></a>
    </div>
</div>